package asteroids.engine.ai;

import asteroids.engine.GameState;

/**
 * Like a Random Pilot, but is more likely to repeat an action than not.
 * 
 * @author whitecd1
 * 
 */
public class StreakyPilot implements Pilot
{
    private int priorOrders;
    private double streakiness;

    public StreakyPilot(double streakiness)
    {
        priorOrders = (int) (Math.random() * 32);
        this.streakiness = streakiness;
    }

    public StreakyPilot()
    {
        this(0.99);
    }

    @Override
    public int getOrders(GameState state)
    {
        for( int i = 0; i < 5; i++ )
        {
            if( Math.random() > streakiness )
            {
                priorOrders = priorOrders ^ (int) Math.pow(2, i);
            }
        }
        return priorOrders;
    }
}
